﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace CrmContacto.Contracts.Contracts
{
    [Serializable]
    [DataContract]
    public class PuntoDeVenta
    {
        public PuntoDeVenta()
        {
            SubPuntosDeVenta = new List<SubPuntoDeVenta>();
        }

        [DataMember]
        public int Id { get; set; }

        [DataMember]
        public string Nombre { get; set; }

        [DataMember]
        public int EmpresaId { get; set; }

        [DataMember]
        public string CodigoExterno { get; set; }

        [DataMember]
        public bool EsFranquicia { get; set; }

        [DataMember]
        public string Duenio { get; set; }

        [DataMember]
        public bool Activo { get; set; }

        [DataMember]
        public bool Outlet { get; set; }

        [DataMember]
        public int? SubPuntoDeVentaIdActual { get; set; }

        public SubPuntoDeVenta SubPuntoDeVentaActual
        {
            get
            {
                return SubPuntosDeVenta.Where(s => s.Id == SubPuntoDeVentaIdActual).SingleOrDefault();
            }
        }

        [DataMember]
        public List<SubPuntoDeVenta> SubPuntosDeVenta { get; set; }

        public string DisplayName
        {
            get
            {
                return string.Format("{0} ({1})", Nombre, CodigoExterno);
            }
        }
    }
}
